names = []
while True:
name = input("Give me a name: ")
if name == 'q':
break
names.append(name)
print(names)
Give me a name: John Give me a name: Peter Give me a name: Michael Give me a name: James Give me a name: Sarah Give me a name: Mary Give me a name: Quinn Give me a name: q ['John', 'Peter', 'Michael', 'James', 'Sarah', 'Mary', 'Quinn']
names = ['Julia', 'Juan', 'George', 'Gina']
print(names)
['Julia', 'Juan', 'George', 'Gina']
names = ['Julia', 'Juan', 'George', 'Gina']
while True:
name = input("Give me a name: ")
if name == 'q':
break
names.append(name)
print(names)
Give me a name: George Give me a name: Carson Give me a name: Carsyn Give me a name: Jack Give me a name: q ['Julia', 'Juan', 'George', 'Gina', 'George', 'Carson', 'Carsyn', 'Jack']
len
¶fruit = ['apple', 'peach', 'pear', 'açaí']
how_many = len(fruit)
print(how_many)
4
for
¶students = ['Julia', 'Juan', 'George', 'Gina']
for name in students:
print(f"Hello {name}. Welcome to CS 110.")
Hello Julia. Welcome to CS 110. Hello Juan. Welcome to CS 110. Hello George. Welcome to CS 110. Hello Gina. Welcome to CS 110.
Write a program that queries the user for a list of numbers (one number at a time).
Then ask the user what number to use as the boundary between "big" and "small" numbers.
Print "You have {how_many} numbers"
Then print the small numbers with the heading "These are small:"
Then print the bit numbers with the heading "These are big:"
Number: 8 Number: 10 Number: 30 Number: 2 Number: 65 Number: 42 Number: 13 Number: 77 Number: q Boundary: 20 You have 8 numbers These are small: 8 10 2 13 These are big: 30 65 42 77
[]
.append(...)
len
for